<template>
<div class="app-container">
    <el-form ref="form" :model="auction" label-width="200px">

        <el-form-item label="保证金">
            <el-input v-model="auction.securityMoney" placeholder="请输入保证金" />
        </el-form-item>
        <el-form-item label="保证金截止时间">
            <el-date-picker v-model="auction.securityMoneyEndTime" type="datetime" placeholder="选择保证金截止时间" default-time="12:00:00">
            </el-date-picker>
        </el-form-item>

        <el-form-item label="开始时间">
            <el-date-picker v-model="auction.startTime" type="datetime" placeholder="选择拍卖开始时间" default-time="12:00:00">
            </el-date-picker>
        </el-form-item>
        <el-form-item label="结束时间">
            <el-date-picker v-model="auction.endTime" type="datetime" placeholder="选择拍卖结束时间" default-time="14:00:00">
            </el-date-picker>
        </el-form-item>

        <el-form-item>
            <el-button type="primary" @click="issue">Issue</el-button>
        </el-form-item>

    </el-form>
</div>
</template>

<script>
export default {
    data: function () {

        return {
            auction: {
                statusId: 1
            },
            goods: {

            }
        }
    },
    created() {

        this.giveId();
        this.getGoodsInfo();
    },
    methods: {

        //发布
        issue() {
            this.auction.goodsType = this.goods.type;
            this.auction.goodsName = this.goods.name;
            console.log(this.auction);
            this.axios({
                url: 'http://localhost:8888/goods/auction/goods/issueGoods',
                method: "post",
                data: JSON.stringify(this.auction),
                headers: {
                    "Content-Type": "application/json",
                },
            }).then(res => {
                if (res.data.code == 200) {
                    //跳转页面
                    this.$message({
                        message: "发布成功",
                        type: "success",
                    });
                    setTimeout(() => {
                        //需要延迟的代码 :3秒后延迟跳转到首页，可以加提示什么的
                        this.$router.push("/basic/goods");
                        //延迟时间：3秒
                    }, 1500);
                }
            })
        },
        //给id赋值

        giveId() {
            this.auction.goodsId = this.$route.params.id;
        },
        //根据id查询商品
        getGoodsInfo() {
            this.auction.goodsId = this.$route.params.id;
            this.axios({
                url: 'http://localhost:8888/goods/auction/goods/selectGoodsById',
                method: 'get',
                params: {
                    id: this.auction.goodsId
                }
            }).then(res => {
                this.goods = res.data.data.goods;

            })
        }
    }

}
</script>

<style>

</style>
